<template>
	<view v-if="nodeList.length" class="article-detail">
		<rich-text :nodes="nodeList"></rich-text>
	</view>
</template>

<script>
	import HtmlParser from '../../utils/html-parser.js'
	export default {
		data() {
			return {
				nodeList: []
			}
		},
			
		onLoad(option) {
			this.getDetail(option.id)
		},
		
		methods: {
			async getDetail(id) {
				let res = await this.$store.dispatch('index/getArticleDetailById', id)
				this.nodeList = new HtmlParser(res.content.trim())
				uni.setNavigationBarTitle({
				    title: res.title
				});
			}
		}
	}
</script>

<style lang="scss">
.article-detail {
	margin: 20rpx;
	padding: 20rpx;
	border-radius: 20rpx;
	background-color: #fff;
}
</style>
